<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String contextPath = request.getContextPath();
	request.setAttribute("xsedit","Y");
	Dingdan dd = (Dingdan) request.getAttribute("dd");
	Map<String,Object> param = new HashMap<String,Object>();
	param.put("khzy",UserContext.getUserContext(request).getUserid());
	String msg = (String)request.getAttribute("msg");
%>
<%@page import="com.zhangyj.component.ToolBar"%>
<%@page import="com.zhangyj.entitis.Dingdan"%>
<%@page import="com.zhangyj.impl.UserContext"%>
<%@page import="java.net.URLEncoder"%>
<%@page import="com.zhangyj.util.Tools"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@include file="/WEB-INF/jsps/head.jsp"%>
<style type="text/css">
.textbox {
	width: 100%;
}
.gridlayout {
width:700px;
}
.gridlayout td {
	height: 30px;
	padding-left: 10px;
}
</style>
<script type="text/javascript">
function uf_selClient() {
	var url= '<%=contextPath%>/selector/hy.do?param=<%=URLEncoder.encode(Tools.object2jsonStr(param),"UTF-8")%>';
	var obj = _open(url,600,800);
	if (obj) {
		var key = "";
		var form = document.forms["form1"];
		for (key in obj) {
			var input = form[key];
			if (input) {
				input.value=obj[key];
			}
		}
	}
}

function uf_selPro() {
	var form = document.forms["form1"];
	var ddid = form["ddid"].value;
	if (ddid == "" || ddid==0) {
		alert("请先保存基本性息！");
		return;
	}
	var url= "<%=contextPath%>/order/xs.do?ddid=" + ddid;
	var obj = _open(url,240,500);
	if (obj) {
		uf_ok();
	}
}
function uf_editPro(xsid) {
	
	var url= "<%=contextPath%>/order/xs.do?xsid=" + xsid;
	var obj = _open(url,240,500);
	if (obj) {
		uf_ok();
	}
}
function zjjs() {
	var form = document.forms["form1"];
	
	var sl = Util.getSelectVal(form["sl"]);
	if (isNaN(sl)) {
		form["sl"].value = sl = 0;
		alert("请输入数字");
	}
	var dj =parseInt( form["dj"].value);
	form["zje"].value = sl * dj
}

function uf_ok() {
	var form = $("form1");

	if (form["hybh"].value == "") {
		alert("请选择会员");
		return;
	}

	form.submit();
}

function validate(){
	alert(1)	
}
function uf_onload() {
	<%if (msg != null) {%>
		alert("<%=msg%>");
	<%}%>
}
</script>
</head>
<body onload="uf_onload()">
<%
	ToolBar toolbar = new ToolBar();
	toolbar.setTitle("订单明细");
	toolbar.put(new ToolBar.Item("选择客户", "uf_selClient()"));
	toolbar.put(new ToolBar.Item("添加产品", "uf_selPro()"));
	if (dd.getDdid() > 0) {
		toolbar.put(new ToolBar.Item("保存", "uf_ok()"));
	} else {
		toolbar.put(new ToolBar.Item("保存", "uf_ok()"));
	}
	toolbar.put(new ToolBar.Item("返回", "_setLocation('" + contextPath
			+ "/order/list.do')"));
	toolbar.writer(out);
%>
<div class="subcontent">
<form id="form1" name="form1" action="<%=contextPath%>/order/save.do"
	method="post"><input  name="ddid" type="hidden"
	value="<%=dd.getDdid()%>" />
	 <input  name="zdrid"  type="hidden"	value="<%=dd.getZdrid()%>" />
	 <input  name="cwsh" type="hidden"  value="<%=dd.getCwsh()%>"/>
	 <%=com.zhangyj.entitis.SystemParam.getSystemParam(request).toInput() %>
<table class="gridlayout">
	<tr>
		<td width="100px">订单编号</td>
		<td width="160px"><input class="textbox" readonly="readonly" name="ddbh"
			value="<%=dd.getDdbh()%>" type="text" /></td>
		<td width="160px">制单时间</td>
		<td width="100px"><input class="textbox" readonly="readonly" name="zdsj"
			value="<%=dd.getZdsj()%>" type="text" /></td>
		<td width="100px">制单人</td>
		<td width="180px"><input class="textbox" readonly="readonly" name="zdr"
			value="<%=dd.getZdr()%>" type="text" /></td>
	</tr>
	<tr>
		<td>会员编号</td>
		<td><input class="textbox" readonly="readonly" name="hybh"
			value="<%=dd.getHybh()%>" type="text" /></td>
		<td>会员姓名</td>
		<td><input class="textbox" readonly="readonly" name="hyxm"
			value="<%=dd.getHyxm()%>" type="text" /></td>
		<td>会员级别</td>
		<td>
			<%=Tools.builderSelect(new String[][]{{"0","普通会员"},{"1","VIP会员"}},"hyjb",dd.getHyjb()) %>
		</td>
	</tr>
	
	<tr>
		<td>总金额</td>
		<td><input class="textbox" name="zje" value="<%=dd.getZje()%>" 	type="text" /></td>
		<td>账户余额</td>
		<td><input class="textbox" readonly="readonly" name="zhye"
			value="<%=dd.getZhye()%>" type="text" /></td>
			<td>支付方式</td>
			<td>
				<%=Tools.builderSelect(new String[][]{{"0","余额支付"},{"1","积分支付"}},"zflx",dd.getZflx()+"") %>
			</td>
	</tr>
	<tr>
		<td>送货地址</td>
		<td colspan="5"><input class="textbox" readonly="readonly"
			name="shdz" value="<%=dd.getShdz()%>" type="text" /></td>
	</tr>
	<tr>
		<td>送货邮编</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="shyb" value="<%=dd.getShyb()%>" type="text" /></td>
		<td>送货电话</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="shdh" value="<%=dd.getShdh()%>" type="text" /></td>
	</tr>


	<tr>
		<td>定单备注</td>
		<td colspan='5'><input class="textbox" name="ddbz"
			value="<%=dd.getDdbz()%>" type="text" /></td>
	</tr>
	<tr>
		<td>内部备注</td>
		<td colspan='5'><input class="textbox" name="nbbz"
			value="<%=dd.getNbbz()%>" type="text" /></td>
	</tr>
	<tr>
		<td>审核人员</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="shry" value="<%=dd.getShry()%>" type="text" /></td>
		<td>审核时间</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="shsj" value="<%=dd.getShsj()%>" type="text" /></td>

	</tr>
	<tr>
		<td>开单人员</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="kdry" value="<%=dd.getKdry()%>" type="text" /></td>
		<td>开单时间</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="kdsj" value="<%=dd.getKdsj()%>" type="text" /></td>
	</tr>
	<tr>
		<td>发货员</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="fhy" value="<%=dd.getFhy()%>" type="text" /></td>
		<td>发货时间</td>
		<td colspan="2"><input class="textbox" readonly="readonly"
			name="fhsj" value="<%=dd.getFhsj()%>" type="text" /></td>
	</tr>
	<tr>
		<td>订单标识</td>
		<td colspan="2"><%=Dingdan.ZFBSLABEL[dd.getZfbs()]%></td>
		<td>财务审核标志</td>
		<td colspan="2"><%=dd.getCwsh()==0?"未审核":"已审核"%></td>
	</tr>
</table>
</form>
<jsp:include page="/workspace/order/productList.jsp"></jsp:include>
</div>
</body>
</html>